package com.company.cloud.article.modules.app.controller;

import com.company.cloud.article.modules.cache.models.ArticleCategoryModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.company.cloud.article.modules.cache.models.ArticleModel;
import com.company.cloud.article.modules.cache.service.ArticleCacheService;
import com.company.cloud.common.bean.BaseResult;
import com.company.cloud.common.utils.AuthContextUtils;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.List;

@RestController
@RequestMapping("/app/cms/articleCategory")
@Api(tags = "App_cms_新闻资讯分类")
public class ArticleCategoryController {

    @Autowired
    private ArticleCacheService articleCacheService;

    @GetMapping("/getTree")
    @ApiOperation(value = "获取树状结构", response = ArticleModel.class)
    public BaseResult getTree() {
        String companyNo = AuthContextUtils.getCompanyNo();
        List<ArticleCategoryModel> data= articleCacheService.getArticleCategoryByCompanyCache(companyNo);
        return BaseResult.ok(data);
    }

}
